<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改活动配置')" />
</head>
<style>
    .in-row{
        clear: both;
    }
    .in-row label{
        float: left;
        width: 75px;
        margin: 5px 5px 5px 5px;
        text-align:right;
    }
    .in-row span{
        float: left;
    }
    .in-row .btn-default{
        float: left;
        color: #555;
        margin-left: 10px;
        padding: 5px 5px;
        border: 1px solid #ddd;
        border-radius: 4px;
        background: transparent;
        outline: none;
        height: 30px;
        width: 100px;
    }
    .in-row div select,.in-row div input {
        float: left;
        border: 1px solid #ddd;
        border-radius: 4px;
        background: transparent;
        outline: none;
        height: 30px;
        width: 100px;
    }
    .border{
        border:1px solid #ddd;
        margin-bottom: 5px;
        padding: 10px 10px 10px 10px;
    }
</style>
<body class="white-bg" style="line-height:2">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <ul class="nav nav-tabs">
            <li class="active"><a data-toggle="tab" href="#activationReturn">激活返现规则</a></li>
            <li class="" ><a data-toggle="tab" href="#standardReturn">交易达标返现规则</a></li>
            <li class="" ><a data-toggle="tab" href="#wjh">未/伪激活规则</a></li>
            <li class="" ><a data-toggle="tab" href="#llf">流量费/服务费返现规则</a></li>
            <li class="" ><a data-toggle="tab" href="#ycjl">隐形奖励规则</a></li>
        </ul>
        <form class="form-horizontal m" id="form-ActActive-edit">
            <div class="tab-content">
                <input type="hidden" name="act_id" th:value="${act_id}">
                <div class="tab-pane active" id="activationReturn">
                    <div>
                        <div class="in-row">
                            <div>
                                <label>返现周期：</label>
                                <select th:id="activationReturnCycle">
                                    <option value="0">日返</option>
                                    <option value="1">月返</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div th:each="model : ${actTerminalModel}" class="in-row" name="activationReturn">
                        <div>
                            <label >终端来源：</label>
                            <select name="source" disabled readonly="readonly">
                                <option value="0" th:selected="${model.SOURCE} eq 0">定制机</option>
                                <option value="1" th:selected="${model.SOURCE} eq 1">自备机</option>
                            </select>
                        </div>
                         <div>
                             <label >终端厂商：</label>
                             <select name="manufacturer" disabled th:selected="${model.MANU_NUM}">
                                 <option value="">全部</option>
                                 <option th:each="manu : ${manufacturer}"
                                         th:value="${manu.MANU_NUM}"
                                         th:text="${manu.MANU_NAME}"
                                         th:selected="${model.MANU_NUM} eq ${manu.MANU_NUM}"></option>
                             </select>
                         </div>
                         <div>
                             <label >终端型号：</label>
                             <select name="terminal_model_id" disabled readonly="readonly">
                                 <option th:value="${model.TERM_NUM}" th:text="${model.MODEL}"></option>
                             </select>
                         </div>
                         <div>
                             <label >缴费类型：</label>
                             <select name="type" onchange="paymentTypeChange(this)" >
                                 <option value="0"th:selected="${model.TYPE} eq 0">服务费</option>
                                 <option value="1"th:selected="${model.TYPE} eq 1">免服务费</option>
                             </select>
                         </div>
                         <div>
                             <label style="width: 100px;">服务费金额：</label>
                             <input type="number" class="form-control" name="return_amount" th:value="${model.RETURN_AMOUNT}">
                         </div>
                        <input type="hidden" name="terminal_fee" th:value="0">
                        <input type="hidden" name="terminal_id" th:value="${model.ID}">
                        <input type="hidden" name="id" th:value="${model.ID}">
                        <input type="hidden" name="act_return_id" th:value="${model[ACT_RETURN_ID] != null?model[ACT_RETURN_ID]:'-1'}">
                    </div>
                </div>
                <div class="tab-pane" id="standardReturn">
                    <div th:each="act : ${actTransactionCompliance}" class="border" name="standardReturn">
                        <h4 class="form-header h4">交易达标/服务费返现</h4>
                        <div class="row">
                            <div class="in-row">
                                <input name="id" th:value="${act.ID}" type="hidden">
                                <div style="margin-left: 5px">
                                    <label class='is-required'>考核期(天)：</label>
                                    <input name="assessment_period" class="is-required" required th:value="${act[ASSESSMENT_PERIOD]}" type="number">
                                </div>
                                <div>
                                    <label>返现类型：</label>
                                    <select name="type" disabled>
                                        <option value="0" th:selected="${act.TYPE} eq 0">交易达标返现</option>
<!--
                                        <option value="1" th:selected="${act.TYPE} eq 1">服务费返现</option>
-->
                                    </select>
                                </div>
                                <div>
                                    <label>返现周期：</label>
                                    <select name="return_cycle" disabled>
                                        <option value="0" th:selected="${act.RETURN_CYCLE} eq 0">日返</option>
                                        <option value="1" th:selected="${act.RETURN_CYCLE} eq 1">月返</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <h4 class="form-header h4"></h4>
                        <div class="row" >
                            <div th:each="paymentType : ${act.paymentType}" name="paymentType" class="in-row">
                                <input name="id" th:value="${paymentType.ID}" type="hidden">
                                <div>
                                    <label >支付类型：</label>
                                    <select name="distribution_type" >
                                        <option value="" th:selected="${paymentType[DISTRIBUTION_TYPE]} eq ''">全部</option>
                                        <option value="0" th:selected="${paymentType[DISTRIBUTION_TYPE]} eq 0">银行卡收单</option>
                                        <option value="2" th:selected="${paymentType[DISTRIBUTION_TYPE]} eq 2">银联二维码</option>
                                        <option value="3" th:selected="${paymentType[DISTRIBUTION_TYPE]} eq 3">微信</option>
                                        <option value="4" th:selected="${paymentType[DISTRIBUTION_TYPE]} eq 4">支付宝</option>
                                    </select>
                                </div>
                                <div>
                                    <label>商户类型：</label>
                                    <select name="mer_type">
                                        <option value="99" th:selected="${paymentType.MER_TYPE} eq 99">全部</option>
                                        <!--<option value="0" th:selected="${paymentType.MER_TYPE} eq 0">标准类</option>
                                        <option value="1" th:selected="${paymentType.MER_TYPE} eq 1">优惠类</option>
                                        <option value="2" th:selected="${paymentType.MER_TYPE} eq 2">减免类</option>-->
                                    </select>
                                </div>
                                <div>
                                    <label>卡类型：</label>
                                    <select name="card_type">
                                        <option value="99" th:selected="${paymentType.CARD_TYPE} eq 99">全部</option>
                                        <option value="0" th:selected="${paymentType.CARD_TYPE} eq 0">借记卡</option>
                                        <option value="1" th:selected="${paymentType.CARD_TYPE} eq 1">贷记卡</option>
                                    </select>
                                </div>
                                <div>
                                    <label>结算类型：</label>
                                    <select name="settlement_type">
                                        <option value="99" th:selected="${paymentType.SETTLEMENT_TYPE} eq 99">全部</option>
                                        <option value="0" th:selected="${paymentType.SETTLEMENT_TYPE} eq 0">D0</option>
                                        <option value="1" th:selected="${paymentType.SETTLEMENT_TYPE} eq 1">T1</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <h4 class="form-header h4"></h4>
<!--
                        <div class="row" style="margin-bottom: 10px">
                            <div class="in-row">
                                <div>
                                    <label>终端类型：</label>
                                    <select name="pos_type">
                                        <option value="0" th:selected="${act.pos_type} eq 0">传统</option>
                                        <option value="4" th:selected="${act.pos_type} eq 4">电签</option>
                                        <option value="5" th:selected="${act.pos_type} eq 5">GB传统</option>
                                        <option value="6" th:selected="${act.pos_type} eq 6">GB电签</option>
                                        <option value="7" th:selected="${act.pos_type} eq 7">GB电签二</option>

                                    </select>
                                </div>
                                <div>
                                    <label class='is-required' >采购人奖励:</label> <div style="margin-left: 100px"></div>
                                    <input required name="buyMoney" class="form-control is-required" type="number" min="0" th:value="${act.buyMoney}" >
                                    <label class='is-required'>（元）</label>
                                </div>
                                <div>
                                    <label class="is-required">团长采购人:</label> <div style="margin-left: 100px"></div>
                                    <input onclick="selectYl()" class="form-control is-required" id="ylIdName" type="text" th:value="${act.ylIdName}" required readonly style="background-color: white" placeholder="无">
                                    <input type="hidden" name="proYlId" id="ylId" th:value="${act.ylId}">
                                    <input type="hidden" name="agentNum" id="agentNum" th:value="${act.agentNum}">
                                </div>
                            </div>
                        </div>
-->

                        <div class="row">
                            <div th:each="stage,stageStat:${act.stage}" name="stage" class="in-row">
                                <input name="id" type="hidden" th:value="${stage.ID}">
                                <div>
                                    <label class='is-required' th:if="${stageStat.index == 0}">激活额(万):</label>
                                    <label class='is-required' th:if="${stageStat.index != 0}">达标额(万):</label>
                                    <input required name="begin_num" class="form-control is-required" type="number" th:value="${stage.BEGIN_NUM}">
                                    <span>-</span>
                                    <input required name="end_num" class="form-control  is-required" type="number" th:value="${stage.END_NUM}">
                                </div>
                                <div>
                                    <label class='is-required' th:if="${stageStat.index == 0}">激活(天):</label>
                                    <label class='is-required' th:if="${stageStat.index != 0}">达标段(天):</label>
                                    <input required name="begin_date" class="form-control is-required" type="number" th:value="${stage[BEGIN_DATE]}">
                                    <span>-</span>
                                    <input required name="end_date" class="form-control is-required" type="number" th:value="${stage[END_DATE]}">
                                </div>
                                <div>
                                    <label class='is-required'>返现额(元):</label>
                                    <input required name="matching_num" class="form-control is-required" type="number" th:value="${stage[MATCHING_NUM]}">
                                </div>
                                <div>
                                    <label class='is-required'>留存额(元):</label>
                                    <input required name="keep_money" class="form-control is-required" type="number" th:value="${stage[KEEP_MONEY]}">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div th:if="${#lists.size(actTransactionCompliance)} eq 0" class="border" name="standardReturn">
                        <div class="row" >
                            <h4 class="form-header h4">交易达标/服务费返现
<!--
                                <button type="button" class="btn btn-default"  onclick="insertStandardReturn(this)">新增</button>
-->
                            </h4>
                        </div>
                        <div class="row" >
                            <input name="id" value="-1" type="hidden">
                            <div class="in-row">
                                <div style="margin-left: 5px">
                                    <label class="is-required">考核期(天)：</label>
                                    <input class="is-required" name="assessment_period" required type="number">
                                </div>
                                <div>
                                    <label>返现类型：</label>
                                    <select name="type">
                                        <option value="0">交易达标返现</option>
<!--
                                        <option value="1">服务费返现</option>
-->
                                    </select>
                                </div>
                                <div>
                                    <label>返现周期：</label>
                                    <select name="return_cycle">
                                        <option value="0">日返</option>
                                        <option value="1">月返</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <h4 class="form-header h4"></h4>
                        <div class="row">
                            <div class="in-row" name="paymentType">
                                <input name="id" value="-1" type="hidden">
                                <div>
                                    <label >支付类型：</label>
                                    <select name="distribution_type">
                                        <option value="">全部</option>
                                        <option value="0">银行卡收单</option>
                                        <option value="2">银联二维码</option>
                                        <option value="3">微信</option>
                                        <option value="4">支付宝</option>
                                    </select>
                                </div>
                                <div>
                                    <label>商户类型：</label>
                                    <select name="mer_type">
                                        <option value="99">全部</option>
                                      <!--  <option value="0">标准类</option>
                                        <option value="1">优惠类</option>
                                        <option value="2">减免类</option>-->
                                    </select>
                                </div>
                                <div>
                                    <label>卡类型：</label>
                                    <select name="card_type">
                                        <option value="99">全部</option>
                                        <option value="0">借记卡</option>
                                        <option value="1">贷记卡</option>
                                    </select>
                                </div>
                                <div>
                                    <label>结算类型：</label>
                                    <select name="settlement_type">
                                        <option value="99">全部</option>
                                        <option value="0">D0</option>
                                        <option value="1">T1</option>
                                    </select>
                                </div>
                                <button type="button" class="btn btn-default"  onclick="insert(this)">新增一行</button>
                            </div>
                        </div>
                        <h4 class="form-header h4"></h4>
<!--
                        <div class="row" style="margin-bottom: 10px">
                            <div class="in-row">
                                <div>
                                    <label>终端类型：</label>
                                    <select name="pos_type">
                                        <option value="4">电签</option>
                                        <option value="0">传统</option>
                                        <option value="5">GB传统</option>
                                        <option value="6">GB电签</option>
                                        <option value="7">GB电签二</option>

                                    </select>
                                </div>
                                <div>
                                    <label class='is-required' >采购人奖励:</label> <div style="margin-left: 100px"></div>
                                    <input required name="buyMoney" class="form-control is-required" min="0" type="number">
                                    <label class='is-required'>（元）</label>
                                </div>
                                <div>
                                    <label class="is-required">团长采购人:</label> <div style="margin-left: 100px"></div>
                                    <input onclick="selectYl()" class="form-control is-required" id="ylIdName" type="text" required readonly style="background-color: white" placeholder="无">
                                    <input type="hidden" name="proYlId" id="ylId">
                                    <input type="hidden" name="agentNum" id="agentNum">
                                </div>
                            </div>
                        </div>
-->
                        <div class="row">
                            <div class="in-row" name="stage">
                                <input name="id" value="-1" type="hidden">
                                <div>
                                    <label class="is-required">激活额(万):</label>
                                    <input required class="is-required" name="begin_num" type="number">
                                    <span>-</span>
                                    <input required class="is-required" name="end_num" type="number">
                                </div>
                                <div>
                                    <label class="is-required">激活(天):</label>
                                    <input required class="is-required" name="begin_date" type="number">
                                    <span>-</span>
                                    <input required class="is-required" name="end_date" type="number">
                                </div>
                                <div>
                                    <label class="is-required">返现额(元):</label>
                                    <input required class="is-required" name="matching_num" type="number">
                                </div>
                                <div>
                                    <label class="is-required">留存额(元):</label>
                                    <input required class="is-required" name="keep_money" type="number">
                                </div>
                                <button type="button" class="btn btn-default" onclick="dbInsert(this)">新增一行</button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="wjh">
                    <div class="in-row" >
                        <div >
                            <label>未激活：</label>
                        </div>
                        <div>
                            <input type="number" class="form-control" name="days1" th:value="${wjh1?.DAYS}">
                        </div>
                        <div >
                            <label style="width: 100px;">天内未激活,扣除</label>
                        </div>
                        <div >
                            <label style="width: 5px;"></label>
                            <input type="number" class="form-control" name="take_money1" th:value="${wjh1?.TAKE_MONEY}">
                        </div>
                        <div >
                            <label style="width: 20px;">元</label>
                        </div>
                    </div>
                    <div class="in-row" >
                        <h4 class="form-header h4" style="margin-bottom: 10px;"></h4>
                        <div >
                            <label>伪激活：</label>
                        </div>
                        <div>
                            <input type="number" class="form-control" name="days" th:value="${wjh?.DAYS}">
                        </div>
                        <div >
                            <label style="width: 90px;">天内交易不满</label>
                        </div>
                        <div>
                            <label style="width: 5px;"></label>
                            <input type="number" class="form-control" name="not_sa_money" th:value="${wjh?.NOT_SA_MONEY}">
                        </div>
                        <div >
                            <label style="width: 50px;">元扣除</label>
                        </div>
                        <div >
                            <label style="width: 5px;"></label>
                            <input type="number" class="form-control" name="take_money" th:value="${wjh?.TAKE_MONEY}">
                        </div>
                        <div >
                            <label style="width: 20px;">元</label>
                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="llf">
                    <div class="in-row" >
                        <div>
                            <label style="width: 160px;">流量卡返现金额(元)：</label>
                            <input type="number" class="form-control" name="sim_fee_return" th:value="${act?.simFeeReturn}">
                        </div>
                        <div>
                            <label style="width: 160px;">流量卡留存金额(元)：</label>
                            <input type="number" class="form-control" name="sim_fee_keep" th:value="${act?.sim_fee_keep}">
                        </div>
                    </div>
                    <div class="in-row" >
                        <div>
                            <label style="width: 160px;">服务费返现金额(元)：</label>
                            <input type="number" class="form-control" name="service_fee_return" th:value="${act?.serviceFeeReturn}">
                        </div>
                        <div>
                            <label style="width: 160px;">服务费留存金额(元)：</label>
                            <input type="number" class="form-control" name="service_fee_keep" th:value="${act?.service_fee_keep}">
                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="ycjl">
                    <div class="in-row" >
                        <h4 class="form-header h4">隐形奖励</h4>
                        <div>
                            <label style="width: 120px;">盟主激活奖励(元):</label>
                            <input type="number" class="form-control" name="award_leader" th:value="${act?.award_leader}">
                        </div>
                        <div >
                            <label style="width: 5px;"></label>
                        </div>
                        <div >
                            <label style="width: 120px;">团长激活奖励(元):</label>
                            <input type="number" class="form-control" name="award_team" th:value="${act?.award_team}">
                        </div>
                        <div >
                            <label style="width: 10px;"></label>
                        </div>
                        <div >
                            <label style="width: 120px;">业务员激活奖励(元):</label>
                            <input type="number" class="form-control" name="award_sales" th:value="${act?.award_sales}">
                        </div>
                    </div>
<!--
                    <div class="in-row" style="margin-top: 100px;">
                        <h4 class="form-header h4">交易奖励</h4>
                        <div>
                            <label style="width: 120px;">交易量大于等于</label>
                            <input type="number" class="form-control" name="award_leader" style="width: 120px;" th:value="${act?.award_leader}">
                        </div>
                        <div >
                            <label style="width: 10px;">元</label>
                        </div>
                        <div >
                            <label style="width: 10px;"></label>
                        </div>
                        <div >
                            <label style="width: 80px;">奖励盟主分润</label>
                            <input type="number" class="form-control" name="award_team" th:value="${act?.award_team}">
                        </div>
                        <div >
                            <label style="width: 10px;"></label>
                        </div>
                        <div >
                            <label style="width: 80px;">奖励业务分润</label>
                            <input type="number" class="form-control" name="award_team" th:value="${act?.award_team}">
                            <label style="width: 90px;"></label>
                        </div>
                    </div>
-->

                </div>

            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "ActActive/ActActive";

        var maxVal = 120;

        function submitHandler() {
            if ($.validate.form()) {
                var data = new Object();
                //激活返现规则
                var activationReturn = new Array();
                $("[name = 'activationReturn']").each(function () {
                    var activationReturnObj = new Object();
                    activationReturnObj.source = $(this).find("[name = 'source']").val();
                    activationReturnObj.manufacturer = $(this).find("[name = 'manufacturer']").val();
                    activationReturnObj.terminal_id = $(this).find("[name = 'terminal_id']").val();
                    activationReturnObj.type = $(this).find("[name = 'type']").val();
                    activationReturnObj.return_amount = $(this).find("[name = 'return_amount']").val();
                    activationReturnObj.id = $(this).find("[name = 'id']").val();
                    activationReturnObj.act_return_id = $(this).find("[name = 'act_return_id']").val();
                    activationReturnObj.terminal_fee = $(this).find("[name = 'terminal_fee']").val();
                    activationReturnObj.return_cycle = $("#activationReturnCycle option:selected").val();
                    activationReturn.push(activationReturnObj)
                });

               data.activationReturn = JSON.stringify(activationReturn);
                //交易达标返现规则
                var standardReturn = new Array();
                $("[name = 'standardReturn']").each(function () {
                    var standardReturnObj = new Object();
                    standardReturnObj.assessment_period = $(this).find("[name = 'assessment_period']").val();
                    if(standardReturnObj.assessment_period){
                        standardReturnObj.return_cycle = $(this).find("[name = 'return_cycle'] option:selected").val();
                        standardReturnObj.type = $(this).find("[name = 'type'] option:selected").val();
                        standardReturnObj.id = $(this).find("[name = 'id']").val();
                        var paymentArray = new Array();
                        $(this).find("[name='paymentType']").each(function () {
                            var paymentObject = new Object();
                            paymentObject.distribution_type = $(this).find("[name = 'distribution_type']  option:selected").val();
                            paymentObject.mer_type = $(this).find("[name = 'mer_type']  option:selected").val();
                            paymentObject.card_type = $(this).find("[name = 'card_type']  option:selected").val();
                            paymentObject.settlement_type = $(this).find("[name = 'settlement_type']  option:selected").val();
                            paymentObject.id = $(this).find("[name = 'id']").val();
                            paymentArray.push(paymentObject);
                        });
                        standardReturnObj.paymentType = JSON.stringify(paymentArray);
                        var stageArray = new Array();
                        $(this).find("[name='stage']").each(function () {
                            var stageObject = new Object();
                            stageObject.id = $(this).find("[name = 'id']").val();
                            stageObject.begin_num = $(this).find("[name = 'begin_num']").val();
                            stageObject.end_num = $(this).find("[name = 'end_num']").val();
                            stageObject.begin_date = $(this).find("[name = 'begin_date']").val();
                            stageObject.end_date = $(this).find("[name = 'end_date']").val();
                            stageObject.matching_num = $(this).find("[name = 'matching_num']").val();
                            stageObject.keep_money = $(this).find("[name = 'keep_money']").val();
                            stageArray.push(stageObject);
                        });
                        standardReturnObj.stage = JSON.stringify(stageArray);
                        standardReturn.push(JSON.stringify(standardReturnObj));
                    }
                });
                data.standardReturn = JSON.stringify(standardReturn);
                //采购人奖励
                data.buyMoney = parseInt($("[name = 'buyMoney']").val());
                data.proYlId = $("[name = 'proYlId']").val();
                data.agentNum = $("[name = 'agentNum']").val();
                data.pos_type = parseInt($("[name = 'pos_type']").val());
                if(data.pos_type == '5'){
                    maxVal = 200;
                }else{
                    maxVal = 120;
                }
                //激活奖励
                data.money = parseInt($("[name = 'matching_num']").val());
                //采购人奖励不得大于120/200元
                if(data.buyMoney > maxVal){
                    $.modal.alertWarning("输入金额有误不得超过"+maxVal+"元");
                    return;
                }
                //采购人奖励和活动奖励之和不得超过120/200元
                if(parseInt(data.buyMoney) + parseInt(data.money) > maxVal){
                    $.modal.alertWarning("输入金额有误,采购人奖励与达标返现金额之和不得超过"+maxVal+"元");
                    return;
                }

                //伪激活
                data.days = $("input[name='days']").val();
                data.not_sa_money = $("input[name='not_sa_money']").val();
                data.take_money = $("input[name='take_money']").val();

                data.days1 = $("input[name='days1']").val();
                data.not_sa_money1 = $("input[name='not_sa_money1']").val();
                data.take_money1 = $("input[name='take_money1']").val();

                data.sim_fee_return = $("input[name='sim_fee_return']").val();
                data.sim_fee_keep = $("input[name='sim_fee_keep']").val();
                data.service_fee_return = $("input[name='service_fee_return']").val();
                data.service_fee_keep = $("input[name='service_fee_keep']").val();

                data.award_leader = $("input[name='award_leader']").val();
                data.award_team = $("input[name='award_team']").val();
                data.award_sales = $("input[name='award_sales']").val();

                $.operate.save(prefix + "/addActReturnMoney", {"act_id":$("[name='act_id']").val(),"data":JSON.stringify(data)});
            }
        }

        function paymentTypeChange(e){
            var paymentType = $(e).find("option:selected").val();
            if (paymentType == '0'){
                $("[name = 'return_amount']").attr("readOnly", false);
            } else if (paymentType == '1'){
                $("[name = 'return_amount']").attr("readOnly", true);
                $("[name = 'return_amount']").val(0);
            }
        }

        function deleteRow(e){
            $(e).parents(".in-row").remove();
        }

        function selectYl() {
            var url =ctx + "finance/agentDeductions"+ "/selectYl?ylId="+$("#ylId").val()+"&ylName=1";
            $.modal.open("选择收款团长" , url, '400');
        }

        /**
         * 新增支付方式节点
         */
        function insert(e){
            var html =
                "<div  class=\"in-row\" name=\"paymentType\">\n" +
                "    <input name=\"id\" value=\"-1\" type=\"hidden\">\n" +
                "    <div>\n" +
                "        <label >支付类型：</label>\n" +
                "        <select name=\"distribution_type\">\n" +
                "            <option value=\"\">全部</option>\n" +
                "            <option value=\"0\">银行卡收单</option>\n" +
                "            <option value=\"2\">银联二维码</option>\n" +
                "            <option value=\"3\">微信</option>\n" +
                "            <option value=\"4\">支付宝</option>\n" +
                "        </select>\n" +
                "    </div>\n" +
                "    <div>\n" +
                "        <label>商户类型：</label>\n" +
                "        <select name=\"mer_type\">\n" +
                "            <option value=\"99\">全部</option>\n" +
                "            <option value=\"0\">标准类</option>\n" +
                "            <option value=\"1\">优惠类</option>\n" +
                "            <option value=\"2\">减免类</option>\n" +
                "        </select>\n" +
                "    </div>\n" +
                "    <div>\n" +
                "        <label>卡类型：</label>\n" +
                "        <select name=\"card_type\">\n" +
                "            <option value=\"99\">全部</option>\n" +
                "            <option value=\"0\">借记卡</option>\n" +
                "            <option value=\"1\">贷记卡</option>\n" +
                "        </select>\n" +
                "    </div>\n" +
                "    <div>\n" +
                "        <label>结算类型：</label>\n" +
                "        <select name=\"settlement_type\">\n" +
                "            <option value=\"99\">全部</option>\n" +
                "            <option value=\"0\">D0</option>\n" +
                "            <option value=\"1\">T1</option>\n" +
                "        </select>\n" +
                "    </div>\n" +
                "    <button type=\"button\" class=\"btn btn-default\"  onclick=\"deleteRow(this)\">删除</button>\n" +
                "</div>";
            $(e).parents(".row").append(html);
        }

        /**
         * 新增阶梯节点
         */
        function dbInsert(e){
            var html =
                "<div class=\"in-row\" name=\"stage\">\n" +
                "    <input name=\"id\" value=\"-1\" type=\"hidden\">\n" +
                "    <div>\n" +
                "        <label class='is-required'>达标额(万):</label>\n" +
                "        <input name=\"begin_num\" class=\"is-required\" type=\"number\" required>\n" +
                "        <span>-</span>\n" +
                "        <input name=\"end_num\" class=\"is-required\" type=\"number\" required>\n" +
                "    </div>\n" +
                "    <div>\n" +
                "        <label class='is-required'>达标段(天):</label>\n" +
                "        <input name=\"begin_date\" class=\"is-required\" type=\"number\" required>\n" +
                "        <span>-</span>\n" +
                "        <input name=\"end_date\" class=\"is-required\" type=\"number\" required>\n" +
                "    </div>\n" +
                "    <div>\n" +
                "        <label class='is-required'>返现额(元):</label>\n" +
                "        <input name=\"matching_num\" class=\"is-required\" type=\"number\" required>\n" +
                "    </div>\n" +
                "    <div>\n" +
                "        <label class='is-required'>留存额(元):</label>\n" +
                "        <input name=\"keep_money\" class=\"is-required\" type=\"number\" required>\n" +
                "    </div>\n" +
                "    <button type=\"button\" class=\"btn btn-default\" onclick=\"deleteRow(this)\">删除</button>\n" +
                "</div>";
            $(e).parents(".row").append(html);
        }

        /**
         * 新增活动返现规则
         */
        function insertStandardReturn(){
            var html = "<div name=\"standardReturn\" class=\"border\">\n" +
                "    <h4 class=\"form-header h4\">交易达标/服务费返现</h4>\n" +
                "    <div class=\"row\" >\n" +
                "        <input name=\"id\" value=\"-1\" type=\"hidden\">\n" +
                "        <div class=\"in-row\">\n" +
                "            <div style=\"margin-left: 5px\">\n" +
                "                <label class='is-required'>考核期(天)：</label>\n" +
                "                <input name=\"assessment_period\" class=\"is-required\" required type=\"number\">\n" +
                "            </div>\n" +
                "            <div>\n" +
                "                <label>返现类型：</label>\n" +
                "                <select name=\"type\">\n" +
                "                    <option value=\"0\">交易达标返现</option>\n" +
                "                    <option value=\"1\">服务费返现</option>\n" +
                "                </select>\n" +
                "            </div>\n" +
                "            <div>\n" +
                "                <label>返现周期：</label>\n" +
                "                <select name=\"return_cycle\">\n" +
                "                    <option value=\"0\">日返</option>\n" +
                "                    <option value=\"1\">月返</option>\n" +
                "                </select>\n" +
                "            </div>\n" +
                "        </div>\n" +
                "    </div>\n" +
                "    <h4 class=\"form-header h4\"></h4>\n" +
                "    <div class=\"row\">\n" +
                "        <div class=\"in-row\" name=\"paymentType\">\n" +
                "            <input name=\"id\" value=\"-1\" type=\"hidden\">\n" +
                "            <div>\n" +
                "                <label >支付类型：</label>\n" +
                "                <select name=\"distribution_type\">\n" +
                "                    <option value=\"\">全部</option>\n" +
                "                    <option value=\"0\">银行卡收单</option>\n" +
                "                    <option value=\"2\">银联二维码</option>\n" +
                "                    <option value=\"3\">微信</option>\n" +
                "                    <option value=\"4\">支付宝</option>\n" +
                "                </select>\n" +
                "            </div>\n" +
                "            <div>\n" +
                "                <label>商户类型：</label>\n" +
                "                <select name=\"mer_type\">\n" +
                "                    <option value=\"99\">全部</option>\n" +
                "                    <option value=\"0\">标准类</option>\n" +
                "                    <option value=\"1\">优惠类</option>\n" +
                "                    <option value=\"2\">减免类</option>\n" +
                "                </select>\n" +
                "            </div>\n" +
                "            <div>\n" +
                "                <label>卡类型：</label>\n" +
                "                <select name=\"card_type\">\n" +
                "                    <option value=\"99\">全部</option>\n" +
                "                    <option value=\"0\">借记卡</option>\n" +
                "                    <option value=\"1\">贷记卡</option>\n" +
                "                </select>\n" +
                "            </div>\n" +
                "            <div>\n" +
                "                <label>结算类型：</label>\n" +
                "                <select name=\"settlement_type\">\n" +
                "                    <option value=\"99\">全部</option>\n" +
                "                    <option value=\"0\">D0</option>\n" +
                "                    <option value=\"1\">T1</option>\n" +
                "                </select>\n" +
                "            </div>\n" +
                "            <button type=\"button\" class=\"btn btn-default\"  onclick=\"insert(this)\">新增一行</button>\n" +
                "        </div>\n" +
                "    </div>\n" +
                "    <h4 class=\"form-header h4\"></h4>\n" +
                /*"<div class=\"row\" style=\"margin-bottom: 10px\">\n" +
                "                            <div class=\"in-row\">\n" +
                "                                <div>\n" +
                "                                    <label>终端类型：</label>\n" +
                "                                    <select name=\"pos_type\">\n" +
                "                                        <option value=\"0\">传统</option>\n" +
                "                                        <option value=\"4\">电签</option>\n" +
                "                                        <option value=\"5\">GB传统</option>\n" +
                "                                        <option value=\"6\">GB电签</option>\n" +
                "                                        <option value=\"7\">GB电签二</option>\n" +

                "                                    </select>\n" +
                "                                </div>\n" +
                "                                <div>\n" +
                "                                    <label class='is-required' >采购人奖励:</label> <div style=\"margin-left: 100px\"></div>\n" +
                "                                    <input required name=\"buyMoney\" class=\"form-control is-required\" min=\"0\" type=\"number\"  >\n" +
                "                                    <label class='is-required'>（元）</label>\n" +
                "                                </div>\n" +
                "                                <div>\n" +
                "                                    <label class=\"is-required\">团长采购人:</label> <div style=\"margin-left: 100px\"></div>\n" +
                "                                    <input onclick=\"selectYl()\" class=\"form-control is-required\" id=\"ylId-Name\" type=\"text\" required readonly style=\"background-color: white\" placeholder=\"无\">\n" +
                "                                    <input type=\"hidden\" name=\"proYlId\" id=\"ylId\">\n" +
                "                                    <input type=\"hidden\" name=\"agentNum\" id=\"agentNum\">\n" +
                "                                </div>\n"+
                "                            </div>\n" +
                "                        </div>"+*/
                "    <div class=\"row\">\n" +
                "        <div class=\"in-row\" name=\"stage\">\n" +
                "            <input name=\"id\" value=\"-1\" type=\"hidden\">\n" +
                "            <div>\n" +
                "                <label class='is-required'>达标额(万):</label>\n" +
                "                <input name=\"begin_num\" class=\"is-required\" type=\"number\" required>\n" +
                "                <span>-</span>\n" +
                "                <input name=\"end_num\" class=\"is-required\" type=\"number\" required>\n" +
                "            </div>\n" +
                "            <div>\n" +
                "                <label class='is-required'>达标段(天):</label>\n" +
                "                <input name=\"begin_date\" class=\"is-required\" type=\"number\" required>\n" +
                "                <span>-</span>\n" +
                "                <input name=\"end_date\" class=\"is-required\" type=\"number\" required>\n" +
                "            </div>\n" +
                "            <div>\n" +
                "                <label class='is-required'>返现额(元):</label>\n" +
                "                <input name=\"matching_num\" class=\"is-required\" type=\"number\" required>\n" +
                "            </div>\n" +
                "            <div>\n" +
                "                <label class='is-required'>留存额(元):</label>\n" +
                "                <input name=\"keep_money\" class=\"is-required\" type=\"number\" required>\n" +
                "            </div>\n" +
                "            <button type=\"button\" class=\"btn btn-default\" onclick=\"dbInsert(this)\">新增一行</button>\n" +
                "        </div>\n" +
                "    </div>\n" +
                "</div>";
            $("#standardReturn").append(html)
        }
    </script>
</body>
</html>
